<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Map类型管理Dom结点</title>
</head>
<body>
    <div name="一个码农">Jimmy</div>
    <div name="码农的女朋友">zhangxue</div>
</body>
<script>
    // document.querySelector('div').addEventListener
    let map = new Map()
    document.querySelectorAll('div').forEach(item=>{
        map.set(item,item.getAttribute('name'))
    })
    console.log(map) // Map(2) {div => "一个码农", div => "码农的女朋友"}

    map.forEach((item,element)=>{
        element.addEventListener('click',()=>{
            alert(item)
        })
    })
</script>
</html>